<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition   xmlns="http://www.w3.org/1999/xhtml"
			      xmlns:h="http://java.sun.com/jsf/html"
				  xmlns:p="http://primefaces.org/ui"
			      xmlns:f="http://java.sun.com/jsf/core"
			      xmlns:ui="http://java.sun.com/jsf/facelets"
			      > 
			      
<p:panel id="panel" header="Filtration Parameters" style="margin-bottom:10px;font-size:14px;"> 

<h:panelGroup>
     <h:messages globalOnly="true"/>
</h:panelGroup>
  
    <p:panelGrid columns="4">
    
    	<h:outputText value="Country: *" /> 
        <p:selectOneMenu style="width:180px" id="MRcountries" value="#{matchingReportManagedBean.country}" required="true" requiredMessage="Required">    
            <f:selectItem itemLabel="--Select Country--" itemValue="" />
            <f:selectItems value="#{servicesManagedBean.allCountriesList}" /> 
            <p:ajax update="MRDistributors" listener="#{matchingReportManagedBean.updateDistributorsList}"/>
        </p:selectOneMenu>
    
    	 <h:outputText value="Distributor ID: *" /> 
    	 <p:selectOneMenu style="width:120px" id="MRDistributors" value="#{matchingReportManagedBean.distributor}" required="true" requiredMessage="Please select distributor ID." >    
            <f:selectItems value="#{matchingReportManagedBean.distList}" />
         </p:selectOneMenu>
      
            
        <h:outputText value="From: *" />  
 		<p:calendar id="MRfrom"  styleClass="calendarFilter" pattern="dd-MMM-yy" value="#{matchingReportManagedBean.from_date}" showOn="button" required="true" requiredMessage="Required">
        </p:calendar>
        
        <h:outputText value="To: *" />
        <p:calendar id="MRto"  styleClass="calendarFilter" pattern="dd-MMM-yy" value="#{matchingReportManagedBean.to_date}" showOn="button" required="true" requiredMessage="Required">
        </p:calendar>
 		
 		<h:outputText value="Grouping Level: " />  
        <p:selectOneRadio id="ReportLevel" value="#{matchingReportManagedBean.groupingLevel}" style="font-size:12px;font-weight:bold;">  
            <f:selectItem itemLabel="Calendar Day" itemValue="#{matchingReportManagedBean.calDay}"/>  
            <f:selectItem itemLabel="Invoice No." itemValue="#{matchingReportManagedBean.invoiceNo}" />  
            <f:selectItem itemLabel="Line ID" itemValue="#{matchingReportManagedBean.lineID}" />  
            <p:ajax update="MatchingPanel" />
        </p:selectOneRadio> 

 		<h:outputText value="Mismatch only: " />  
        <p:selectBooleanCheckbox value="#{matchingReportManagedBean.mismatchingChecked}">  
            <p:ajax update="MatchingPanel" listener="#{matchingReportManagedBean.updateMatchingList}"/>  
        </p:selectBooleanCheckbox> 
        
 		<p:commandButton value="Call" update="MatchingPanel @form" actionListener="#{matchingReportManagedBean.callMatchingProcedure}"/>
 		<h:commandLink>  
        <p:graphicImage value="NWDSAKMS-excel-logo.png" width="30" height="30" title="Export to Excel"  style="border:0;margin-left:5px"/>  
        <p:dataExporter type="xls" target="#{matchingReportManagedBean.groupingLevel}Datatable" fileName="Sales_Matching_#{servicesManagedBean.dateNow}" />  
    	</h:commandLink>               
      </p:panelGrid>  
       
 </p:panel>  
 
 <p:panel id="MatchingPanel">
 <p:dataTable   id="#{matchingReportManagedBean.calDay}Datatable" style="margin-top:5px"
			  	var="matchRow" value="#{(matchingReportManagedBean.mismatchingChecked)?matchingReportManagedBean.filtdaylist:matchingReportManagedBean.daylist}"
			  	rendered="#{(matchingReportManagedBean.groupingLevel == matchingReportManagedBean.calDay) and matchingReportManagedBean.procedureCalled}"  
              	paginator="true" 
              	rows="30"   
              	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
              	rowsPerPageTemplate="20,40,60,80" 
              	lazy="true" 
              	rowStyleClass="#{matchRow.color}"   
              >  
        <f:facet name="header">  
            Matching Report (Calendar_Day Level) 
        </f:facet> 
        <p:column style="background:#FFFFFF">  
            <f:facet name="header">  
                    <h:outputText value="Distributor" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.distributorNo}" />  
        </p:column>  
  
        <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Invoice Date" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.invoiceDate}" />  
        </p:column>  
        
       <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Customer No" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.outletId}" />  
        </p:column>  
  		
        <p:column style="background:#DCDCDC">
        <f:facet name="header">  
                    <h:outputText value="Namehub GSV" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.namehubGsv}" /> 
        </p:column>  
        
        <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="Chub GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubGsv}" />
        </p:column> 
        
            <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="File GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileGsv}" />
        </p:column> 
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header">  
                   <h:outputText value="Namehub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.namehubQty}" />
        </p:column>
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="Chub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubQty}" />
        </p:column>
        
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="File QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileQty}" />
        </p:column>
       
   
    </p:dataTable>
    
    
    <p:dataTable   id="#{matchingReportManagedBean.invoiceNo}Datatable" style="margin-top:5px"
			  	var="matchRow" value="#{(matchingReportManagedBean.mismatchingChecked)?matchingReportManagedBean.filtinvlist:matchingReportManagedBean.invlist}"
			  	rendered="#{(matchingReportManagedBean.groupingLevel == matchingReportManagedBean.invoiceNo) and matchingReportManagedBean.procedureCalled}"  
              	paginator="true" 
              	rows="30"   
              	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
              	rowsPerPageTemplate="20,40,60,80" 
              	lazy="true" 
              	rowStyleClass="#{matchRow.color}"   
              >  
        <f:facet name="header">  
            Matching Report (Invoice_No Level)  
        </f:facet> 
        <p:column style="background:#FFFFFF">  
            <f:facet name="header">  
                    <h:outputText value="Distributor" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.distributorNo}" />  
        </p:column>  
  
        <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Invoice Date" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.invoiceDate}" />  
        </p:column>  
  
  		<p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Invoice NO" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.invoiceNo}" />  
        </p:column>  
        
        <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Customer NO" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.outletId}" />  
        </p:column> 
 	
        <p:column style="background:#DCDCDC">
        <f:facet name="header">  
                    <h:outputText value="Namehub GSV" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.namehubGsv}" /> 
        </p:column>  
        
        <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="Chub GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubGsv}" />
        </p:column> 
        
            <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="File GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileGsv}" />
        </p:column> 
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header">  
                   <h:outputText value="Namehub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.namehubQty}" />
        </p:column>
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="Chub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubQty}" />
        </p:column>
        
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="File QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileQty}" />
        </p:column>
       
   
    </p:dataTable> 
    
    
    <p:dataTable   id="#{matchingReportManagedBean.lineID}Datatable" style="margin-top:5px"
			  	var="matchRow" value="#{(matchingReportManagedBean.mismatchingChecked)?matchingReportManagedBean.filtlinlist:matchingReportManagedBean.linlist}"
			  	rendered="#{(matchingReportManagedBean.groupingLevel == matchingReportManagedBean.lineID) and matchingReportManagedBean.procedureCalled}"    
              	paginator="true" 
              	rows="30"   
              	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
              	rowsPerPageTemplate="20,40,60,80" 
              	lazy="true" 
              	rowStyleClass="#{matchRow.color}"   
              >  
        <f:facet name="header">  
            Matching Report (Line_ID Level) 
        </f:facet> 
        <p:column style="background:#FFFFFF">  
            <f:facet name="header">  
                    <h:outputText value="Distributor" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.distributorNo}" />  
        </p:column>  
  
        <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Invoice Date" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.invoiceDate}" />  
        </p:column>  
  
  		<p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Invoice NO" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.invoiceNo}" />  
        </p:column>  
        
       <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Customer NO" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.outletId}" />  
        </p:column>  
        
        <p:column style="background:#FFFFFF">  
            <f:facet name="header" >  
                    <h:outputText value="Line ID" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.lineId}" />  
        </p:column>  
  		
        <p:column style="background:#DCDCDC">
        <f:facet name="header">  
                    <h:outputText value="Namehub GSV" style="color:black"/> 
            </f:facet>  
            <h:outputText value="#{matchRow.namehubGsv}" /> 
        </p:column>  
        
        <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="Chub GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubGsv}" />
        </p:column> 
        
            <p:column style="background:#DCDCDC">
        <f:facet name="header" >  
                    <h:outputText value="File GSV" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileGsv}" />
        </p:column> 
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header">  
                   <h:outputText value="Namehub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.namehubQty}" />
        </p:column>
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="Chub QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.chubQty}" />
        </p:column>
        
        
        <p:column style="background:#B8B8B8">
        <f:facet name="header" >  
                    <h:outputText value="File QTY" style="color:black"/>
            </f:facet>  
            <h:outputText value="#{matchRow.ftpfileQty}" />
        </p:column>
       
   
    </p:dataTable>  
    </p:panel>
</ui:composition>